package com.gxg.demo10.mydemo11.dati;

import android.support.v4.view.PagerAdapter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.alfredayibonte.questionnaireviewlib.models.Question;
import com.gxg.demo10.mydemo11.BaseApplication;
import com.gxg.demo10.mydemo11.R;

public class DaTiActivity extends AppCompatActivity  implements QuestionFragment.OnQuestionItemSelectedListener {
    private NonSwipeableViewPager mPager;
    private PagerAdapter mPagerAdapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_da_ti);
        mPager = (NonSwipeableViewPager)findViewById(R.id.pager);
        BaseApplication app = (BaseApplication) getApplication();
        mPagerAdapter = new QuestionPagerAdapter(getApplicationContext(),
                getSupportFragmentManager(), app.getQuestions());
        mPager.setAdapter(mPagerAdapter);
    }

    @Override
    public void onPreviousButtonPressed(Question question) {
        int page = mPager.getCurrentItem();
        mPager.setCurrentItem( page - 1 );
    }

    @Override
    public void onNextButtonPressed(Question question) {
        int page = mPager.getCurrentItem();
        mPager.setCurrentItem( page + 1 );
    }
}
